<?php

namespace app\demo\controller;

use yunj\Controller;

class ValidateDemo extends Controller {

    public function demo() {
        $data = [
            "username" => "xiaowang",
            "password" => "123456",
        ];
        $validate = new \app\demo\validate\FormDemo();
        $res = $validate->scene("Test")->check($data);
        if ($res) {
            // 验证通过，获取处理后的数据
            $data = $validate->getData();
            dump($data);
        } else {
            // 验证失败，获取失败信息
            $error = $validate->getError();
            dump($error);
        }
    }

}